package my.webservices.util;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * SpringUtil is a utility for retrieving spring context.
 * 
 * @author Nilaksh Bajpai.
 */
public final class SpringUtil {

    /** Spring application context. */
    private static ClassPathXmlApplicationContext context;

    static {
        getApplicationContext(new String[] { "testApplicationContext.xml" });
    }

    /**
     * Creates a new SpringUtil object.
     */
    private SpringUtil() {
    }

    /**
     * Retrieve the application context.
     * 
     * @return Returns the context.
     */
    public static ApplicationContext getApplicationContext() {
        return context;
    }

    /**
     * Retrieve the application context.
     * 
     * @param files
     * @return Returns the context.
     */
    public static ApplicationContext getApplicationContext(String[] files) {
        context = new ClassPathXmlApplicationContext(files);
        return context;
    }
}
